import {
  Toast
} from "vant";
import cTitle from "components/title";
import {
  scrollMixin
} from "../../../utils/mixin";
export default {
  mixins: [scrollMixin], //加载更多
  data() {
    return {
      list: [
        // {
        //   order_sn: 'hjhsjjsjsjjssjsj',
        //   created_at: '2024-10-24 15:48:11',
        //   member_info: {
        //     uid: 11111,
        //     avatar: 'https://ide.code.fun/api/image?token=6719b911c471750012dcd82c&name=b0646a57620f6ba0f25c9d56b38fa91c.png',
        //     nickname: 'dsssss'
        //   },
        //   order_goods: [
        //     {
        //       title: '商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称',
        //       thumb: 'https://ide.code.fun/api/image?token=6719b911c471750012dcd82c&name=245bf8367cfa8331b778e8f84d5b9dd5.png',
        //       total: 2,
        //       guige: '红色',
        //       price: '4498.00'
        //     },
        //     {
        //       title: '商品名称商品名称商品名称商品名称',
        //       thumb: 'https://ide.code.fun/api/image?token=6719b911c471750012dcd82c&name=245bf8367cfa8331b778e8f84d5b9dd5.png',
        //       total: 2,
        //       guige: '红色',
        //       price: '4498.00'
        //     }
        //   ]
        // },
        // {
        //   order_sn: 'hjhsjjsjsjjssjsj',
        //   created_at: '2024-10-24 15:48:11',
        //   member_info: {
        //     uid: 11111,
        //     avatar: 'https://ide.code.fun/api/image?token=6719b911c471750012dcd82c&name=b0646a57620f6ba0f25c9d56b38fa91c.png',
        //     nickname: 'dsssss'
        //   },
        //   order_goods: [
        //     {
        //       title: '商品名称商品名称商品名称商品名称',
        //       thumb: 'https://ide.code.fun/api/image?token=6719b911c471750012dcd82c&name=245bf8367cfa8331b778e8f84d5b9dd5.png',
        //       total: 2,
        //       guige: '红色',
        //       price: '4498.00'
        //     }
        //   ]
        // }
      ],
      userId: '',
      total: 0, //订单总数
      money: 0, //订单总金额
      isLoadMore: true,
      page: 1,
      total_page: 0,
    };
  },

  components: {
    cTitle
  },
  activated() {
    console.log(localStorage.getItem("uid"), 'uid')
    if (!localStorage.getItem("uid")) {
      this.$router.push(this.fun.getUrl("member"));
      return
    }
    this.getData();
  },
  computed: {

  },
  methods: {
     //获取更多数据
     getMoreData() {
      console.log("hongbao", this.isLoadMore);
      if (!this.isLoadMore) return;
      this.isLoadMore = false; // 防止多次请求分页数据
      if (this.page >= this.total_page) {
        Toast('到底了')
        return;
      } else {
        this.page += 1;
        this.getData();
      }
    },
    searchOrder() {
      console.log(this.userId, 'userId')
      this.list = [];
      this.getData();
    },
    getData() {
      $http.post("HuiMing.teamOrder", {
        page: this.page,
        uid: localStorage.getItem("uid") ? localStorage.getItem("uid") : '',
        child_id: this.userId
      }, "加载中").then((res) => {
        if (res.result == 1) {
          console.log(res, 'teamOrder')
          var nextPageData = res.data.data;
          this.list = [...this.list, ...nextPageData];
          this.total = res.data.total; //订单总数
          this.money = res.data.money_sum; //订单总金额
          this.total_page = res.data.last_page;
          this.isLoadMore = true;
        } else {
          this.isLoadMore = false;
          Toast(res.msg)
        }
      });
    },

  }
};